import {reqGoodsDetailInfo} from '@/api'
const state = {
    goodsDetailInfo:{}
};
const mutations = {
    REQ_GOODSDETAILINFO(state,goodsDetailInfo){
        state.goodsDetailInfo = goodsDetailInfo;
    }
};
const actions = {
    async getGoodsDetailInfo({commit},skuId){
        const result = await reqGoodsDetailInfo(skuId);
        if(result.code === 200){
            commit('REQ_GOODSDETAILINFO',result.data)
        }
    }
};
const getters = {
    categoryView(state){
        return state.goodsDetailInfo.categoryView || {};//面包屑数据
    },
    skuInfo(state){
        return state.goodsDetailInfo.skuInfo || {};//商品信息包括放大镜
    },
    spuSaleAttrList(state){
        return state.goodsDetailInfo.spuSaleAttrList || [];
    }
};

export default {
    state,
    actions,
    mutations,
    getters,
}